package com.handong.handserialprogram.utils;

import android.app.Activity;
import android.view.View;

import com.handong.handserialprogram.R;
import com.handong.handserialprogram.widget.component.MutiComponent;
import com.handong.handserialprogram.widget.component.SimpleComponent;
import com.handong.handserialprogram.widget.guideview.Component;
import com.handong.handserialprogram.widget.guideview.Guide;
import com.handong.handserialprogram.widget.guideview.GuideBuilder;

/**
 * Created by userKey on 2017/12/1.
 */

public class UserGuideUtil {

    public static Guide showBindRingGuideView(View view, int res, Activity activity,
                                              GuideBuilder.OnVisibilityChangedListener listener) {
        float dpi = SystemUtil.displayMetricsDpi(activity.getApplicationContext());
        GuideBuilder builder = new GuideBuilder();
        builder.setTargetView(view)
                .setFullingViewId(res)
                .setAlpha(150)
                .setHighTargetCorner(Math.round(15 * dpi))
                .setHighTargetPadding(Math.round(5 * dpi))
                .setHighTargetPaddingLeft(Math.round(6 * dpi))
                .setOverlayTarget(false)
                .setAutoDismiss(true)
                .setOutsideTouchable(false);
        builder.setOnVisibilityChangedListener(listener);
        builder.addComponent(new SimpleComponent("请先给犯人设置电子脚环！"));
        Guide guide = builder.createGuide();
        guide.setShouldCheckLocInWindow(true);
        guide.show(activity);
        return guide;
    }

    public static Guide showActivateGuideView(View guideView, int resID, Activity activity,
                                             GuideBuilder.OnVisibilityChangedListener listener) {
        GuideBuilder localGuideBuilder = new GuideBuilder();
        float dpi = SystemUtil.displayMetricsDpi(activity.getApplicationContext());
        localGuideBuilder.setTargetView(guideView)
                .setFullingViewId(resID)
                .setAlpha(150)
                .setHighTargetCorner(Math.round(30 * dpi))
                .setHighTargetPadding(Math.round(6 * dpi))
                .setOverlayTarget(false).setAutoDismiss(true).setOutsideTouchable(false);
        localGuideBuilder.setOnVisibilityChangedListener(listener);
        localGuideBuilder.addComponent(new SimpleComponent("执行任务前,请先激活脚环") {
            public int getFitPosition() {
                return Component.FIT_END;
            }
        });
        Guide guide = localGuideBuilder.createGuide();
        guide.setShouldCheckLocInWindow(true);
        guide.show(activity);
        return guide;
    }


    public static Guide showRingItemBandGuide(View view, int resId, Activity activity,
                                      GuideBuilder.OnVisibilityChangedListener listener) {
        float dpi = SystemUtil.displayMetricsDpi(activity.getApplicationContext());
        GuideBuilder builder = new GuideBuilder();
        builder.setTargetView(view)
                .setFullingViewId(resId)
                .setAlpha(150)
                .setHighTargetPaddingTop(-Math.round(3 * dpi))
                .setHighTargetPaddingBottom(-Math.round(3 * dpi))
                .setHighTargetCorner(Math.round(15 * dpi))
                .setOverlayTarget(false)
                .setAutoDismiss(true)
                .setOutsideTouchable(false);
        builder.setOnVisibilityChangedListener(listener);
        builder.addComponent(new MutiComponent(R.string.tip_bind_ring));
        Guide guide = builder.createGuide();
        guide.setShouldCheckLocInWindow(true);
        guide.show(activity);
        return guide;
    }

    public static Guide showChooseCriminalGuide(View view, int resId, Activity activity,
                                                GuideBuilder.OnVisibilityChangedListener listener){
        float dpi = SystemUtil.displayMetricsDpi(activity.getApplicationContext());
        GuideBuilder builder = new GuideBuilder();
        builder.setTargetView(view)
                .setFullingViewId(resId)
                .setAlpha(150)
                .setHighTargetPaddingTop(-Math.round(dpi * 8))
                .setHighTargetPaddingBottom(-Math.round(dpi * 8))
                .setHighTargetPaddingLeft(Math.round(dpi * 5))
                .setHighTargetPaddingRight(Math.round(dpi * 5))
                .setHighTargetCorner(Math.round(dpi * 10))
                .setOverlayTarget(false)
                .setAutoDismiss(true)
                .setOutsideTouchable(false);
        builder.setOnVisibilityChangedListener(listener);
        builder.addComponent(new MutiComponent(R.string.tip_choose_criminal));
        Guide guide = builder.createGuide();
        guide.setShouldCheckLocInWindow(true);
        guide.show(activity);
        return guide;
    }
}
